<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //  遍历所有的字符 
        var str = '黑色';
        // 1 . 索引号
        for (var i = 0; i < str.length; i++) {
            console.log(str.charAt(i));  
        }
        // 2. for —— in 
        for(var i in str){
            console.log(i,str[i]);  // i  索引号 
        }
        // 3. for-- of
        for(var i of str){
            console.log(i);
        }
    </script>
</body>

</html>